
#include <stdio.h>
#include <stdlib.h>
void swap(int *x, int *y)
{
	int temp = *x;
    *x = *y;
    *y = *x;
}
void swap2(int **x, int **y)
{
	int *tmp = *x;
    *x = *y;
    *y = tmp;
}

int main()
{
	int a = 10;
    int b = 20;
	/*在子函数中改变当前变量的值，需要传递要改变变量的地址*/
	//swap(&a, &b);
	//printf("a = %d, b = %d\n", a, b);

	int *p = &a;
    int *q = &b;
    /*在该函数中使得p指向b ,使q指向a*/
	/*在子函数中改变当前变量的值，需要传递要改变变量的地址*/
	swap2(&p, &q);
	printf("*p = %d, *q= %d\n", *p, *q);
	return 0;

}


